package com.example.demo01.controllter.test;

import com.google.gson.Gson;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.http.converter.json.GsonBuilderUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author admin
 * @Description 计算三角形面积
 * @date 2020-07-27 13:37:00
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Triangle {

    private Integer length;

    private Integer weight;

    public int triangleArea() {
        return length * weight;
    }

    public static void main(String[] args) {
        Triangle triangle = new Triangle(5, 2);
        System.out.println("triangle.triangleArea() = " + triangle.triangleArea());
        List<Map<String, Object>> objects = new ArrayList<>(16);
        List<String> objectsString = new ArrayList<>();
        objectsString.add("1111");
        objectsString.add("2222");
        objectsString.add("3333");
        objectsString.add("4444");
        System.out.println(new Gson().toJson(objectsString));
        System.out.println(objectsString);
        Map<String, Object> map = new HashMap<>(16);
        map.put("1", "1");
        map.put("2", "2");
        map.put("3", "3");
        map.put("4", "4");
        objects.add(map);
        System.out.println(new Gson().toJson(objects));
        System.out.println(objects);
    }

}
